<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .box{
            width: 300px;
            height: 340px;
            margin: 50px auto;
            border: 1px solid #000000;
        }
        .top{
            font-size: 0;
        }
        .top button{
            width: 60px;
            height: 40px;
            font-size: 18px;
            border: none;
            outline: none;
        }
        .box>.top>button.selected{
            background-color: green;
            color: red;
        }
        .bottom div{
            background-color: yellow;
            height: 300px;
            display: none;
            text-align: center;
            line-height: 300px;
        }
        .box>.bottom>.cs:nth-child(1){
            display: block;
        }
    </style>
    <script>
        window.onload = function(){
            var buttons = document.querySelectorAll("button")
            var bottoms = document.getElementsByClassName('bottom')[0].children
            for(var j=0;j<buttons.length;j++){
                buttons[j].index = j
                buttons[j].onclick = function(){
                    for(var i=0;i<buttons.length;i++){
                        buttons[i].className = ""
                        bottoms[i].style.display="none"
                    }
                    this.className='selected'
                    bottoms[this.index].style.display="block"
                }
            }
        }
    </script>
</head>
<body>
    <div class="box">
        <div class="top">
            <button class="selected">按钮1</button>
            <button>按钮2</button>
            <button>按钮3</button>
            <button>按钮4</button>
            <button>按钮5</button>
        </div>
        <div class="bottom">
            <div class="cs">盒子1</div>
            <div class="cs">盒子2</div>
            <div class="cs">盒子3</div>
            <div class="cs">盒子4</div>
            <div class="cs">盒子5</div>
        </div>
    </div>
</body>
</html>